import requests from "./ajax";
// 引入mock模拟数据的ajax实例
import mockAjax from "./mockAjax";

// 首页三级联动
export const reqCategoryList = () => {
    return requests({url: '/product/getBaseCategoryList', method: 'get'})
}

// 搜索页面数据
export const reqGetSearch = (params) => {
    return requests({url: '/list', method: 'post', data: params})
}

// 获取产品详情
export const reqGoodsInfo = (skuId) => {
    return requests({url: `/item/${skuId}`, method: 'get'})
}

// 加购产品
export const reqAddOrUpdataCart = (skuId, skuNum) => {
    return requests({url: `/cart/addToCart/${skuId}/${skuNum}`, method: 'post'})
}

// 获取购物车列表数据
export const reqCartList = () => {
    return requests({url: '/cart/cartList', method: 'get'})
}

// 删除购物车产品的接口
export const reqDeleteCartById = (skuId) => {
    return requests({url: `/cart/deleteCart/${skuId}`, method: 'delete'})
}

// 获取验证码
export const redGetCode = (phone) => {
    return requests({url: `/user/passport/sendCode/${phone}`, method: 'get'})
}

// 注册
export const reqUserRegister = (params) => {
    return requests({url: '/user/passport/register', data: params, method: 'post'})
}

// 登陆
export const reqUserLogin = (params) => {
    return requests({url: '/user/passport/login', data: params, method: 'post'})
}

//获取用户信息[需要带着用户的token向服务器索要用户信息]
export const reqUserInfo = () => {
    return requests({url: '/user/passport/auth/getUserInfo', method: 'get'})
}

// 退出登陆
export const reqLogout = () => {
    return requests({url: '/user/passport/auth/logout', method: 'get'})
}

// 获取用户地址信息
export const reqAddressInfo = () => {
    return requests({url: '/user/userAddress/auth/findUserAddressList', method: 'get'})
}

// 获取用户购物车商品清单
export const reqOrderInfo = () => {
    return requests({url: 'order/auth/trade', method: 'get'})
}

// 提交订单的接口
export const reqSubmitOrder = (tradeNo, data) => {
    return requests({url: `/order/auth/submitOrder?tradeNo=${tradeNo}`, data, method: 'post'})
}

// 获取支付信息
export const reqPayInfo = (realOrderId) => {
    return requests({url: `/payment/weixin/createNative/${realOrderId}`, method: 'get'})
}

// 获取订单的支付状态
export const reqPayStatus = (realOrderId) => {
    return requests({url: `/payment/weixin/queryPayStatus/${realOrderId}`, method: 'get'})
}

// 获取个人中心的数据
export const reqMyOrderList = (page, limit) => {
    return requests({url: `/order/auth/${page}/${limit}`, method: 'get'})
}
//*********************************************************************************************************
// mock模拟数据
// 模拟banner轮播图数据
export const reqBannerList = () => {
    return mockAjax({url: '/banner', method: 'get'})
}
// 模拟floor轮播图数据
export const reqFloorList = () => {
    return mockAjax({url: '/floor', method: 'get'})
}